-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[API compatibility] add new API paddle.Tensor.requires_grad
#74491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #74491 +/- ##
==========================================
Coverage ? 79.16%
==========================================
Files ? 3
Lines ? 24
Branches ? 0
==========================================
Hits ? 19
Misses ? 5
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
paddle.Tensor.requires_grad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Category
User Experience
PR Types
New features
Description
This PR adds a
requires_grad
property to Paddle Tensors to provide compatibility and improve user experience.What's added:
requires_grad
property to Tensor class across all execution modes (dynamic graph, static graph, and PIR)requires_grad
is the inverse ofstop_gradient
(requires_grad=True means stop_gradient=False)Key features:
not self.stop_gradient
, allowing users to check if gradient computation is enabledself.stop_gradient = not value
Files modified:
python/paddle/base/dygraph/math_op_patch.py
- Dynamic graph mode supportpython/paddle/base/layers/math_op_patch.py
- Static graph mode supportpython/paddle/pir/math_op_patch.py
- PIR mode supporttest/legacy_test/test_tensor_requires_grad.py
- Comprehensive test suite